package com.ifonly.utils;

import com.google.common.io.ByteSource;
import com.google.common.io.Resources;

import java.io.IOException;
import java.net.URL;
import java.util.Properties;

/**
 * @author <a href="mailto:ifonlymaster@163.com">ifonly</a>
 * @version 1.0 2015-12-09 13:45
 * @since JDK 1.6
 */
public class ResourcesUtils {

    public static void loadFileInProperties(String resourceName, Properties properties) {
        URL url = Resources.getResource(resourceName);
        if(url == null) {
            throw new IllegalArgumentException("Parameter of file can not be blank");
        } else {
            ByteSource byteSource = Resources.asByteSource(url);

            try {
                properties.load(byteSource.openStream());
            } catch (IOException var5) {
                throw new IllegalArgumentException("Properties file can not be loading: " + url);
            }
        }
    }



}
